const { ListNode, LinkedList } = require('../2. 链表/1. 链表基础/1. 建立线性链表.js')
// 给定一个已排序的链表的头head
// 要求删除所有重复的元素，使每个元素只出现一次，返回已排序的链表
function deleteDuplicates(head) {
    if (head === null) {
        return head
    }
    let cur = head
    while (cur.next) {
        if (cur.val === cur.next.val) {
            cur.next = cur.next.next
        } else {
            cur = cur.next
        }
    }
    return head
}

const node = new LinkedList([1, 1, 2, 3, 3])
let result = deleteDuplicates(node.head)
console.log(result);